#include "streamUtil.hpp"
#include "exceptions.hpp"

#include <iomanip>
#include <algorithm>

namespace hms {


std::string unexpectedToken( std::istream& is )
{
	/* store stream position to reset it later */
	std::streampos pos { is.tellg() };
	std::string str;
	is >> str;
	is.clear();
	/* reset stream position */
	is.seekg( pos );
	return str;
}

auto toLower( std::string& str ) -> std::string& {
	std::for_each( str.begin(), str.end(),
		[](char& c){ c = ::tolower(c); }
	);
	return str;
}

auto toLower( std::string&& str ) -> std::string {
	toLower(str);
	return str;
}

}